import java.util.Scanner;

//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int t = 0;
        if(a > b){
            t = a;
            a = b;
            b = t;
        }
        for(int i = a; i > 0;i--){
            if(a % i == 0&&b % i == 0){
                    System.out.println(i);
                    break;
            }
        }
    }
}